﻿using MainView.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MainView
{
    public partial class OperationForm : Form
    {
        public OperationForm()
        {
            InitializeComponent();
        }

        public static string roomStr { get; private set; } = MainView.Properties.Settings.Default.roomStr;
        public static int roomNum { get; private set; } = MainView.Properties.Settings.Default.roomNum;

        private void OperationForm_Load(object sender, EventArgs e)
        {
            this.Width = 1920;
            this.Height = 1080;
            UPRoomOper();
            try
            {
                flowLayoutPanel1.Controls.Clear();
                foreach (var Th in RoomOper.RoomOperDic)
                {                 
                    flowLayoutPanel1.Controls.Add(Th.Value.devOper);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
              
            }
        }

        /// <summary>
        /// 更新房间名的显示
        /// </summary>
        public static void UPRoomOper()
        {
            RoomOper.RoomOperDic.Clear();           
            string[] roomName = new string[roomNum];
            try
            {
                roomName = roomStr.Split(',');
                for (int i = 0; i < 6; i++)
                {
                    var id = i;
                    var addr = i.ToString();
                    var name = roomName[i];
                    RoomOper.RoomOperDic.Add(id, new RoomOper(id,name));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);              
            }
        }
    }
}
